<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

  <head>
    <title>修改</title>
    <LINK href="<%=basePath%>resources/css/stylesMonitor.css" type=text/css rel=stylesheet>

   <script type="text/javascript">
  	function checkForm(){
  		var oForm = document.forms[0];
  		
  		if(oForm.hostTypeId.value.length==0){
  			alert("请选择类型");
  			return false;
  		}
  		if(oForm.name.value.length==0){
  			alert("机器名不能为空");
  			return false;
  		}
  		if(oForm.name.value.length>100){
  			alert("机器名长度不能大于100");
  			return false;
  		}
  		if(oForm.address.value.length==0){
  			alert("存放地址不能空");
  			return false;
  		}
  		if(oForm.address.value.length>200){
  			alert("存放地址长度不能大于200");
  			return false;
  		}
  		if(oForm.ip.value.length==0&&oForm.ipInNet.value.length==0){
  			alert("外网ip和内网ip不能都为空");
  			return false;
  		}
  		if(oForm.ip.value.length>50){
  			alert("外网ip长度不能大于50");
  			return false;
  		}
  		if(oForm.ipInNet.value.length>50){
  			alert("内网ip长度不能大于50");
  			return false;
  		}
  		
  		return true;
  	}
  </script>
  </head>

  <body>
    <div class="ContentContainer">
      <div id="divListContainer">
 		<form action="<%=basePath%>host/edit" method="post" onsubmit="return checkForm()">

   		<div>
        <table class="ContentTable" style="width:700px" align="center">
         
          <tr align="center">
            <td  class="EditTableHeader" width="600px" align="center" height="80px" colspan="2"><span>修改主机</span></td>
          </tr>
          <input type="hidden" name="id"  value=${host.id} />
     	 <tr align="center">
            <td class="Label" width="200px" align="right" height="40px">类型：&nbsp;&nbsp;</td>
            <td class="Field" width=400px align="left" >
            	<select name="hostTypeId" >
   					 <c:forEach items="${hostTypeList}" var="hostType">
				     <c:if test="${host.hostTypeId==hostType.id}">
				     	<option value=${hostType.id} selected="selected">${hostType.name}</option>
				     	</c:if>   
				     	<c:if test="${host.hostTypeId!=hostType.id}">  
				     	<option value=${hostType.id}>${hostType.name}</option>
				     	</c:if> 
   					 </c:forEach>
				</select>
				<font color="#ff0000"><span>*</span></font><font color="#ff00ff"><span id="mes"></span></font>
            </td>
             
          </tr>
          
          <tr align="center">
            <td class="Label1" width="200px" align="right" height="40px">机器名：&nbsp;&nbsp;</td>
            <td class="Field1" width=400px align="left" >
            	<input type="text" size="30" name="name" value="${host.name}"/>
				  <font color="#ff0000"><span>*</span></font>
            </td>
          </tr>
        
          <tr align="center">
            <td class="Label1" width="200px" align="right" height="40px">存放地址：&nbsp;&nbsp;</td>
            <td class="Field1" width=400px align="left" >
            	<input type="text" size="30" name="address" value="${host.address}"/>
				  <font color="#ff0000"><span>*</span></font>
            </td>
          </tr>
            <tr align="center">
            <td class="Label1" width="200px" align="right" height="40px">运营商：&nbsp;&nbsp;</td>
            <td class="Field1" width=400px align="left" >
            	<input type="text" size="30" name="telecom" value="${host.telecom}" />
            </td>
             
          </tr>
          <tr align="center">
            <td class="Label1" width="200px" align="right" height="40px">外网IP地址：&nbsp;&nbsp;</td>
            <td class="Field1" width=400px align="left" >
            	<input type="text" size="30" name="ip" value="${host.ip}" />
            </td>
             
          </tr>
          
          <tr align="center">
            <td class="Label1" width="200px" align="right" height="40px">内网IP地址：&nbsp;&nbsp;</td>
            <td class="Field1" width=400px align="left" >
            	<input type="text" size="30" name="ipInNet" value="${host.ipInNet}"/>
            </td>
          </tr>
          
          <tr align="center">
            <td class="Label1" width="200px" align="right" height="40px">操作系统：&nbsp;&nbsp;</td>
            <td class="Field1" width=400px align="left" >
            	<input type="text" size="30" name="operatingSystem" value="${host.operatingSystem}"/>
            </td>
          </tr>
          <c:choose> 
          <c:when test="${sessionScope.popedom == 1}"> 
				 <tr align="center">
		            <td class="Label1" width="200px" align="right" height="40px">登陆端口号：&nbsp;&nbsp;</td>
		            <td class="Field1" width=400px align="left" >
		            	<input type="text" size="30" name="remotePoint" value="${host.remotePoint}" />
		            </td>
		          </tr>
		          
		          
		          <tr align="center">
		            <td class="Label1" width="200px" align="right" height="40px">登陆用户名：&nbsp;&nbsp;</td>
		            <td class="Field1" width=400px align="left" >
		            	<input type="text" size="30" name="loginName" value="${host.loginName}" />
		            </td>
		          </tr>
		          
		          <tr align="center">
		            <td class="Label1" width="200px" align="right" height="40px">登陆密码：&nbsp;&nbsp;</td>
		            <td class="Field1" width=400px align="left" >
		            	<input type="text" size="30" name="loginPwd" value="${host.loginPwd}"/>
		            </td>
		          </tr>	
		 </c:when> 
		 <c:otherwise> 
		 		<input type="hidden" size="30" name="remotePoint" value="${host.remotePoint}" />
		 		<input type="hidden" size="30" name="loginName" value="${host.loginName}" />
		 		<input type="hidden" size="30" name="loginPwd" value="${host.loginPwd}" />
      	 </c:otherwise> 	
         </c:choose>
         
          <tr align="center">
            <td class="Label1" width="200px" align="right" height="40px">备注：&nbsp;&nbsp;</td>
            <td class="Field1" width=400px align="left" >
           	 <textarea rows="6" cols="40" name="remark" >${host.remark}</textarea>
            </td>
          </tr>
          
          <tr align="center">
            <td class="EditTableHeader" colspan="2"  align="center" >
           		 <input type="submit" name="button2"  value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="reset" value="重写" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" name="button3"  value="返回" style="width=60px" onclick="javascript:backtohost()"/> &nbsp;&nbsp;&nbsp;&nbsp;
            </td>
          </tr>
      </table>
      
      <p align="center">
		
		</p>
	</div>
  	</form>
  	</div>
  	  <script type="text/javascript">
	function backtohost(){
		window.location.href='<%=basePath%>host/toHost?id='+${host.id};
	}
	</script>
  </div>
</body>

</html>
